import { IFeidaoAiBrowserComponent } from '@feidao/web/interfaces';
import P03 from './P03';
import nodejs from '@feidao/web/atom/nodejs/msg-b/nodejs';
import render from '@feidao/web/atom/browser/render/render';
import { Handle } from '@feidao/web/node_modules/@feidao/core/on';





export default async function a001(fd: IFeidaoAiBrowserComponent, ...args: any[]) {
	const exam_subjects_name=document.querySelector<HTMLInputElement>("#exam_subjects_name").value;

	const department_no=document.querySelector<HTMLSelectElement>('[data-feidao-id="department"]').value;

	const major_no=document.querySelector<HTMLSelectElement>('[data-feidao-id="major"]').value;

	fd.data.criteria = {
		exam_subjects_name: {
			$regex: '.*' + exam_subjects_name + '.*',
			$options: "i"
		},
		department_no,
		major_no
	};

	const param = {
		criteria: fd.data.criteria,
		page_size: 0,
		page_no: 1
	};

	const res = await nodejs('flippedclass', 'exam_subjects_find', param);
	console.warn('.................. ynn ..................', res);

	if (res.dataArray.length === 0) {
		render(fd, [], P03, 'P03', "inner");
	} else {
		render(fd, res.dataArray, P03, 'P03', "inner");
	}

	const items = document.querySelectorAll<HTMLInputElement>('[data-feidao-item]');

	console.log('items',items);

	Array.from(items).forEach((i) => {
	fd.parse_event(i);
	});

}